import java.io.IOException;
import java.util.*;
import java.io.*;

public class Game {
	private int win= 0;
	private int firingMalazor = 0;
	private int repeat1 = 0;
	private int repeat3 = 0;
	private int repeat2 = 0;
	private int health = 100;
	private int enemyGame = 0;
	private int change  = 0;
	private int dodge  = 0 ;
	private int damage = 0 ;
	private int heal   = 0 ;
	private int enemyDodge = 0 ;
	private int enemyHealth = 100;
	private int charge = 0 ;
	private int fordify = 0;
	private int money = 999999;
	private int enemyDamage = 0;
	private char character; 
	private int avoid= 0 ;
	private String secondRoom;
	private int gun= 0 ;
	private int bullets = 24;
	private int firstTime = 20;
	private int secondTime = 30;
	private Boolean safe= false;
	private String firstRoom = "";
	
	public void firstRoom(int s){
		while (repeat1 == 0 && firstTime>0 ){
		  Game g = new Game();
		
    		
    	
    			System.out.println("The first thing you see is a safe. What do you do?");
    			System.out.println("A: Lockpick it (you must be a robber ");
    			System.out.println("B: Use C-4 to blow up the safe");
    			System.out.println("C: Randomly enter numbers for a minute.");
    			System.out.println("D: Examine the room.");
    			Scanner room = new Scanner(System.in);
    			firstRoom = room.next();
    			if (firstRoom.substring(0,1).equals ("a")|| firstRoom.substring(0,1).equals ("A")){
    				if (s == 2 && firstTime >= 15){
    					System.out.println("It takes you a couple of minutes using a paperclip you found in the desk but you find 50,000$");
    					firstTime = firstTime - 15 ;
    					System.out.println("Unfortunatly you have only "+firstTime+" minutes left");
    					money = money + 50000;
                		firstRoom="D";
                		
                	}else if (firstTime <15){
        				System.out.println("You don't have enough time");
        			}
                	else {
                		System.out.println("You are not a robber and after 10 minutes of trying to pick the lock you fail.");
                		firstTime = firstTime -10;
                	}
                }
                else if(firstRoom.substring(0,1).equals ("b")|| firstRoom.substring(0,1).equals ("B")){
                	System.out.println("You have no C-4");
                	repeat2 = 0;
                	
                }
                else if(firstRoom.substring(0,1).equals ("c")|| firstRoom.substring(0,1).equals ("C")){
                	Random randomGenerator = new Random();
                	int code = (randomGenerator.nextInt(100)) + 1 ;
                	firstTime = firstTime - 1;
                
                	if (code==100){
                		System.out.println("It takes you a couple of minutes randomly guessing number you find the right combo and get 50,000$");
                		System.out.println("Unfortunatly you have only " + firstTime + " minutes left");
                		money = money + 50000;
                		firstRoom="D";
                		
                	}
                	else{
                		System.out.println("You guessed incorrectly");
                		System.out.println("You have only " + firstTime + " minutes left");
                	}
                	
                		
        		
                
    		
    
    
    
               }
                else if (firstRoom.substring(0,1).equals ("d")|| firstRoom.substring(0,1).equals ("D")){
    				repeat1 = 1;
    			}
         
		}  
	}
	public void secondRoom (int s){
		while (repeat2 == 0 && firstTime>0 ){
		  Game g = new Game();
		System.out.println("The next thing you see  is a computer. What do you do?");
		System.out.println("A: Hack it (you must be a tax evader) ");
		System.out.println("B: Use C-4 to blow up the computer");
		System.out.println("C: Randomly enter passwords for a minute.");
		System.out.println("D: Examine the room.");
		Scanner room2 = new Scanner(System.in);
		secondRoom = room2.next();
		if (secondRoom.substring(0,1).equals ("a")|| secondRoom.substring(0,1).equals ("A")){
			
			if (s == 2 && firstTime >=15){
				System.out.println("It takes you a couple of minutes using your awesome hacking skills but you find the password");
				firstTime = firstTime - 15 ;
				System.out.println("Unfortunatly you have only "+firstTime+" minutes left");
				System.out.println("Now that you have hacked into the computer you have 2 options?");
				System.out.println("A: Hack into the ID database and print out an ID badge");
				System.out.println("B: Hack into the guards bank account");
				Scanner com = new Scanner(System.in);
				String computer = com.next();
				if (computer.substring(0,1).equals ("a")|| computer.substring(0,1).equals ("A")){
					System.out.println("You print out an ID card with your picture. Hello Mr.Anderson");
					g.setAvoid(5);
					secondRoom="D";
				}
				else if(computer.substring(0,1).equals ("b")|| computer.substring(0,1).equals ("B"))
					System.out.println("You add $50,000 to your bank account.");
				money = money + 50000;
				secondRoom="D";
        		
        	}
			else if (firstTime <15){
				System.out.println("You don't have enough time");
			}
        	else {
        		System.out.println("You are not a tax evader and after 10 minutes of trying to hack the computer you fail.");
        		firstTime = firstTime-10;
        		
        	}
        }
        else if(secondRoom.substring(0,1).equals ("b")|| secondRoom.substring(0,1).equals ("B")){
        	System.out.println("You have no C-4");
        	repeat2 = 0;
        }
        else if(secondRoom.substring(0,1).equals ("c")|| secondRoom.substring(0,1).equals ("C")){
        	Random randomGenerator = new Random();
        	int code = (randomGenerator.nextInt(100)) + 1 ;
        	firstTime = firstTime - 1;
        
        	if (code==100){
        		System.out.println("It takes you a couple of minutes randomly guessing number you find the right combo and get 50,000$");
        		System.out.println("Unfortunatly you have only " + firstTime + " minutes left");
        		money = money + 50000;
        		firstRoom="D";
        	}
        	else{
        		System.out.println("You guessed incorrectly");
        		System.out.println("You have only " + firstTime + " minutes left");
        	}
        	
        }
		if (secondRoom.substring(0,1).equals ("d")|| secondRoom.substring(0,1).equals ("D")){
			repeat2 = 1;
		}
		
	}
	}
public void thirdRoom (int s){
		while (repeat3 == 0 && firstTime>0){
		System.out.println("You examine the beaten old filing cabinet and find several names that you reconize?");
		System.out.println("A: Your grandmother.");
		System.out.println("B: You best friend from middle school.");
		System.out.println("C: You.");
		System.out.println("D: Examine the room.");
		Scanner file = new Scanner(System.in);
		String cabinit = file.next();
		
		if (cabinit.substring(0,1).equals ("a")|| cabinit.substring(0,1).equals ("A")){
					firstTime = firstTime - 1;
					System.out.println("You look into the file and see the solem sight of your grandmother in black and white poseing for mug shots. ");
					System.out.println("It appears that she was arrested for 'Poisoning the Minds of Tommorrow' by feeding her treasonous cookies full of 'evil love'.");
					System.out.println("In short she was arrested as a goverment disenter. ");
					System.out.println("Would you like to examine more documents? Yes or No.");
					Scanner more = new Scanner(System.in);
					String documents = more.next();
					if (documents.substring(0,1).equals ("y")|| documents.substring(0,1).equals ("Y")){
						repeat3 = 0;
					}
					else{
						cabinit="D";
						repeat3 = 1;
					}
		
        	
        }
        else if(cabinit.substring(0,1).equals ("b")|| cabinit.substring(0,1).equals ("B")){
        	System.out.println("In the file is a picture of your friends smiling face as he looks out of a World War 2 style Panzer under the picture is the caption:  ");
        	System.out.println("' The newly 'elected' dictator of Austrailia goes for a joy ride.'");
        	System.out.println("Would you like to examine more documents? Yes or No.");
			Scanner more = new Scanner(System.in);
			String documents = more.next();
			firstTime = firstTime - 1;
			if (documents.substring(0,1).equals ("y")|| documents.substring(0,1).equals ("Y")){
				repeat3 = 0;
			}
			else{
				cabinit="D";
				
			}
        }
        else if(cabinit.substring(0,1).equals ("c")|| cabinit.substring(0,1).equals ("C")){
        	firstTime = firstTime - 1;
        	if (s==1){
        	System.out.println("As you look at the details of the arrest the document says that you threated that Captin of the Police Force");
        	System.out.println(". He then pulled out his gun and treatened to shoot. Needless to say it was a quick trial");
        	}
        	else if (s==2){
        	System.out.println("You pull out a hefty file and throw it on a table. Pictures, articles, and other 'evidence of henise misdeeds' spew onto the table.");
        	System.out.println("They show the person you truly are, a man of the people, a freedom fighter. You fought against the evils of a tyranical goverment.");
        	}
        	else if (s==3){
        	System.out.println("As you open up the file you see yourself posing for a security cammera holding two large bags of jewels outside Buckingham Palace. ");
        	System.out.println("Under the picture the caption reads 'nearly a million dollars are still missing'.");
        	}
        	else if (s==4){
        	System.out.println("As you open the file you see the face of you most dreaded enemy Evgod. This man is a mass murdering assasin. ");
        	System.out.println("This man was a prominent man in your tribe who rose to power by killing and assasinating all those with more power than he. ");
        	System.out.println("However, according to the file,  this 'kind-hearted' dictator's life was threatetened when the notourious assasin, you.");
        	System.out.println("Would you like to examine more documents? Yes or No.");
        	}
        	Scanner more = new Scanner(System.in);
			String documents = more.next();
			if (documents.substring(0,1).equals ("y")|| documents.substring(0,1).equals ("Y")||documents.substring(0,1).equals ("y")){
				repeat3 = 0;
			}
			else{
				repeat3 =1;
				
			}
        	}
			
        	
        	
        
		else if (cabinit.substring(0,1).equals ("d")|| cabinit.substring(0,1).equals ("D")){
			repeat3 = 1;
		}
}
	}
	public int  getfirstTime(){
		return firstTime;
	}
	public void setAttack(int input){
		damage = damage + 2;
	}
	public void setMoney(int input){
		money = money + input;
	}
	public void setAvoid(int input){
		
		avoid =avoid + input ;
	}
	public void setRandAvoid(){
		Random randomGenerator = new Random();
	    
		change  = change + (randomGenerator.nextInt(100)) + 1 ;
		avoid = avoid + change;
		
	}
	public void setGun(int input){
		gun = input;
	}
	public int getAvoid(){
		return avoid;
		
	}
	public void zeroAvoid(){
		avoid = avoid - change;
		change = 0;
	}
	public int getGun(){
		return gun;
	}
	
	public int getMoney(){
		return money;
	}
	public void end(){
		System.out.println("You have " + money + "$ left.");
		System.out.println("You have " + health +  " health left.");
	}
	public void setfiringMalazor(int input){
		firingMalazor = input;
	}
	public void setEnemyHealth(int enemy){
		Random randomGenerator = new Random();
		if (enemy == 2){
			enemyHealth = 110;
		}
		else if (enemy == 3){
			enemyHealth = 105;
		}
		
		int randomEnemy = (randomGenerator.nextInt(10)) + 1 ;
		if (enemy==1){
			enemyHealth = 100 + randomEnemy;
		
		}
		}
	public void setEnemy(int enemy){
		enemyGame = enemy;
		Random randomGenerator = new Random();
if (enemy==1){
	int randomEnemy2 = (randomGenerator.nextInt(5)) + 1; 
	enemyDodge = enemyDodge + randomEnemy2;
	enemyDamage = enemyDamage + randomEnemy2;
}
if (enemy==2){
	int randomEnemy2 = (randomGenerator.nextInt(10)) + 1; 
	enemyDodge = enemyDodge + randomEnemy2;
	enemyDamage = enemyDamage + randomEnemy2;
}
if (enemy==3){
	int randomEnemy2 = (randomGenerator.nextInt(8)) + 1; 
	enemyDodge = enemyDodge + randomEnemy2;
	enemyDamage = enemyDamage + randomEnemy2;
}
}
	public void setCharacterHealth(int character){
		if (character == 1){
			health = health + 20;
			System.out.println("You are good at not dying, but bad at healing");
			
			
			
		}
		if (character==4){

			System.out.println("You are good at killing people , doing damage but not taking it.");
			health = health - 5;
			
			
		}
		if (character==3){

			System.out.println("You are good at dodging");
			health = health - 5;
			
			
		}
		if (character==2){
			System.out.println("You are good at healing, but have low damage and low health");
			health = health - 15;
			
		}

		
	}
	public  int game(int character) {
	

/*System.out.println("Welcome to Basic RPG. The most basic of all RPG's.");
System.out.println("Would you like to be Strength oriented (s) and do more damage, Dexterity oriented(d) and dodge more damage, or Constitution orianted(c) and have more life?");
Scanner scan = new Scanner(System.in);
int character = scan.nextInt();*/

Random randomGenerator = new Random();
while (health > 0 && enemyHealth > 0){
	if (health > 0 ){
	dodge  = 0 ;
	damage = 0 ;
	heal   = 0 ;
	enemyDodge = 0 ;
	fordify = 0;
	enemyDamage = 0;

if (enemyGame==1){
	int randomEnemy2 = (randomGenerator.nextInt(5)) + 1; 
	enemyDodge = enemyDodge + randomEnemy2;
	enemyDamage = enemyDamage + randomEnemy2;
}
if (enemyGame==2){
	enemyDamage = enemyDodge + 8;
	enemyDamage = enemyDamage + 8;
}
if (enemyGame==3){
	enemyDamage = enemyDodge + 4;
	enemyDamage = enemyDamage + 4;
}

	if (character == 1){
		heal = heal - 5;
		damage = damage + 2;
	}
if (character==2){
	heal = heal + 5;
	damage = damage -2;
}


if (character==3){
	dodge = dodge + 4;
	damage = damage -1;
	
	
}

if (character==4){
	damage = damage + 6;
	

	
}


	System.out.println("It is your turn would you like to attack(a), charge up a roundhouse kick (s) ,this takes 2 turns , or  fortify  , which heals and reduces the damage taken(f), or fire a gun ,if you have it(g).");
	Scanner scanner = new Scanner(System.in);
	String choice = scanner.nextLine();
	choice = choice.substring(0);
	if (choice.equals ("a")|| choice.equals ("A")){
		fordify = 0;
		
		enemyDodge = enemyDodge + (randomGenerator.nextInt(10)) + 1 ;
		if (enemyDodge<10){
		 damage = damage + (randomGenerator.nextInt(10)) + 5 ;
		 System.out.println("You did " + damage + " points of damage.");
		 enemyHealth = enemyHealth - damage;
		 
		 System.out.println("The enemy now has " + enemyHealth + " life left .");
		}
		else {
 			System.out.println("You missed the enemy");
 			System.out.println("The enemy now has " + enemyHealth + " life left .");
		}
	}
	
	else if (choice.equals ("s")||choice.equals ("S")){
			fordify = 0;

			if (charge == 0){
				charge ++;
			}
			else if (charge == 1) {
				System.out.println("Super attack.");
				
				enemyDodge = enemyDodge + (randomGenerator.nextInt(10)+ 1) ;
				if (enemyDodge<10){
					damage = damage + ((randomGenerator.nextInt(20))) + 10 ;
					System.out.println("You did " + damage + " points of damage.");
					enemyHealth = enemyHealth - damage;
					
					System.out.println("The enemy now has " + enemyHealth + " life left .");
					charge = 0 ;
				}
				else {
		 			System.out.println("You missed the enemy");
		 			System.out.println("The enemy now has " + enemyHealth + " life left .");
				}
	
		
			}
	
	}
	else if ( choice.equals("f")|| choice.equals("F")) {
		if (health>110){
		heal = heal + (randomGenerator.nextInt(10)) + 1 ;
		health = health + heal;
		System.out.println("You healed: "+ heal);
		enemyDamage = enemyDamage - 4 ;
		}
		else {
			System.out.println("You can't heal any more");
		}

	}
	else if ( firingMalazor==1){
		enemyHealth= 0;
	}
	else if ( choice.equals("fail")){
		health= 0;
	}
	else if ((choice.equals ("g")|| choice.equals ("G"))){
	if (gun== 1){
		fordify = 0;
		if (bullets > 0 ){
		enemyDodge = enemyDodge + (randomGenerator.nextInt(5)) + 1 ;
		if (enemyDodge<10){
		 damage = damage + (randomGenerator.nextInt(10)) + 10 ;
		 System.out.println("You did " + damage + " points of damage.");
		 enemyHealth = enemyHealth - damage;
		 System.out.println("The enemy now has " + enemyHealth + " life left .");
		 bullets = bullets - 1;
		}
		else {
 			System.out.println("You missed the enemy");
 			System.out.println("The enemy now has " + enemyHealth + " life left .");
 			 bullets = bullets - 1;
 			System.out.println("You have " + bullets + " bullets left.");
		}
		}
		else{
			System.out.println("You have no more bullets");
		}
	}
	else {
		System.out.println("You have no gun.");
	}
	}
	if ( enemyHealth>0){
		System.out.println("It is now the enemy's turn");
		
		dodge = dodge + (randomGenerator.nextInt(5)) + 5 ;
		if (dodge<10){
			enemyDamage = enemyDamage + (randomGenerator.nextInt(5)) + 5 ;
			System.out.println("You took " + enemyDamage + " damage.");
			health = health - enemyDamage;
			
			System.out.println("You now have " + health + " life left .");
		}	
		else {
					System.out.println("The enemy misses you.");
					System.out.println("You now have " + health + " life left .");
		}
	}
}

if ( health <= 0 ){
	System.out.println("You have died");
	win = 0 ;
}
else if ( enemyHealth <= 0 ){
	System.out.println("You have won");
	win = 1;
}

}

return win;
}
	
}


